.panel.panel-default
  .panel-heading
    .row
      .col-sm-6
        h5
          small
            a[data-placement="right"
              data-toggle="popover"
              data-container=".panel-heading"
              data-content="<p>Information about the namespace.</p>"
              data-original-title="What's this?"
              tabindex="0" data-html="true"]
                i.fa.fa-info-circle
          strong
            '#{@namespace.clean_name}
          ' namespace
      .col-sm-6.text-right
        - if can_manage_namespace?(@namespace)
          button.btn.btn-link.btn-xs.btn-edit-role[
            value="#{@namespace.id}" id="edit_namespace" class="button_namespace_description"]
            i.fa.fa-pencil
            | Edit namespace

  .panel-body
    .description
      - if @namespace.description.blank?
        p
          'No description has been posted yet.
      - else
        = markdown(@namespace.description)
    .collapse id="change_description_namespace_#{@namespace.id}"
      = form_for @namespace, remote: true, html: {role: 'form'} do |f|
        .form-group
          = f.label :team, "Team", {class: 'control-label col-md-2'}
          .remote
            = f.text_field(:team, value: "#{@namespace.team.name}", class: 'form-control typeahead', required: true, placeholder: "Name of the team")
        .form-group
          = f.label :description, {class: 'control-label col-md-2'}
          = f.text_area(:description, class: 'form-control fixed-size', placeholder: html_escape(@namespace.description))
        .form-group
          br
            = button_tag(type: 'submit', class: 'btn btn-primary pull-right') do
              i.fa.fa-check
              | Save

        .errors
  .panel-footer

.panel.panel-default
  .panel-heading
    .row
      .col-xs-6
        - if current_user.admin? || @namespace.team.users.include?(current_user)
          .dropdown.align-top-inline
            i.btn.btn-options.fa.fa-ellipsis-v.fa-fw[aria-expanded="false" aria-haspopup="true" data-toggle="dropdown" type="button"]
            ul.dropdown-menu
              li
                a.btn.btn-link.btn-xs.btn-show-webhooks[
                  value="#{@namespace.id}" class="button_namespace_description"
                  href=url_for(namespace_webhooks_path(@namespace))
                  ]
                  i.fa.fa-eye
                  | Show webhooks
        h5.align-top-inline
          'Namespace:
          strong
            = @namespace.clean_name
        - unless @namespace.global? || @namespace.team.hidden?
          .clearfix
            h6.label.label-info#team-label
              | <span>Belongs to: </span>
              = link_to "#{@namespace.team.name}", @namespace.team
      .col-xs-6.text-right
        - if can_push?(@namespace)
          .circle-label.permissions-label.circle-label-sm[data-placement="left"
            data-toggle="popover"
            data-container=".panel-heading"
            data-content="You can push images"
            data-original-title="What can I do?"
            tabindex="0" data-html="true"]
              i.fa.fa-arrow-up
              ' Push
        - if can_pull?(@namespace)
          .circle-label.permissions-label.circle-label-sm[data-placement="left"
            data-toggle="popover"
            data-container=".panel-heading"
            data-content="You can pull images"
            data-original-title="What can I do?"
            tabindex="0" data-html="true"]
            i.fa.fa-arrow-down
            ' Pull
        - if owner?(@namespace)
          .circle-label.permissions-label.circle-label-sm[data-placement="left"
            data-toggle="popover"
            data-container=".panel-heading"
            data-content="You are an owner of this namespace"
            data-original-title="What's my role?"
            tabindex="0" data-html="true"]
            i.fa.fa-male
            ' Owner
        - elsif contributor?(@namespace)
          .circle-label.permissions-label.circle-label-sm[data-placement="left"
            data-toggle="popover"
            data-container=".panel-heading"
            data-content="You are a contributor in this namespace"
            data-original-title="What's my role?"
            tabindex="0" data-html="true"]
            i.fa.fa-exchange
            ' Contr.
        - elsif viewer?(@namespace)
          .circle-label.permissions-label.circle-label-sm[data-placement="left"
            data-toggle="popover"
            data-container=".panel-heading"
            data-content="You are a viewer in this namespace"
            data-original-title="What's my role?"
            tabindex="0" data-html="true"]
            i.fa.fa-eye
            ' Viewer
  .panel-body
    .table-responsive
      table.table.table-stripped.table-hover
        col.col-60
        col.col-40
        thead
          tr
            th Repository
            th # Tags
        tbody
          - @repositories.each do |repository|
            tr
              td= link_to repository.name, repository
              td= repository.tags.count
  .panel-footer= paginate(@repositories)
